Misc improvements to pincpu stuff.
3fbe2f12ltvweb13kBSsxqzZDAq4sg tools/examples/listdoms.py
3fca7788tBihusQSq3HJI-YKQTN2iQ tools/examples/mynewdom.py
3fca7700PVj36cZObaFZlQicRiw1pQ tools/examples/pincpu.py
+3fccbe068ov0YCxnk-2m4law19QMmA tools/examples/startdom.py
3fbe2f12Bnt8mwmr1ZCP6HWGS6yvYw tools/examples/stopdom.py
3f776bd2Xd-dUcPKlPN2vG89VGtfvQ tools/misc/Makefile
3f6dc136ZKOjd8PIqLbFBl_v-rnkGg tools/misc/miniterm/Makefile
#!/usr/bin/env python
-#
-# Example script for creating and building a new Linux guest OS for Xen.
-#
+# Example script for creating and building a new Linux guest OS for
+# Xen. THIS IS VERY SITE SPECIFIC, but shows an example configuration
+# using multiple root partitions with a common /usr. e.g. Domain1
+# uses root /dev/sda8, usr /dev/sda6, and the next sequential IP address.
import Xc, XenoUtil, sys, os, socket, re
# STEP 3. A handy name for your new domain.
domain_name = "My new domain"
-# Allocate new domain
+# Allocate new domain ad get its domain id
xc = Xc.new()
id = xc.domain_create( mem_kb=memory_megabytes*1024, name=domain_name )
if id <= 0:
print "Error creating domain"
sys.exit()
-# Set the CPU, or leave to round robin
+# Set the CPU, or leave to round robin allocation
#xc.domain_pincpu( dom=id, cpu=1 )
# STEP 4. Specify IP address, netmask and gateway for the new domain.
-ipaddr = XenoUtil.add_to_ip(XenoUtil.addr_of_iface('eth0'),id)
+ipaddr = XenoUtil.add_offset_to_ip(XenoUtil.get_current_ipaddr(),id)
netmask = XenoUtil.get_current_ipmask()
gateway = XenoUtil.get_current_ipgw()
# Destroy specified domain.
#
-import Xc, sys, re
+import Xc, sys, re, time
xc = Xc.new()
print "Specify a domain identifier and CPU"
sys.exit()
-xc.domain_pincpu( dom=int(sys.argv[1]), cpu=int(sys.argv[2]))
+dom = int(sys.argv[1])
+cpu = int(sys.argv[2])
+
+orig_state = xc.domain_getinfo(first_dom=dom, max_doms=1)[0]['stopped']
+
+while xc.domain_getinfo(first_dom=dom, max_doms=1)[0]['stopped'] != 1:
+ xc.domain_stop( dom=dom )
+ time.sleep(0.1)
+
+xc.domain_pincpu( dom, cpu )
+
+if orig_state == 0:
+ xc.domain_start( dom=dom )
+
+
+
--- /dev/null
+#!/usr/bin/env python
+
+#
+# Start execution of specified domain.
+#
+
+import Xc, sys, re
+
+xc = Xc.new()
+
+if len(sys.argv) != 2:
+ print "Specify a domain identifier"
+ sys.exit()
+
+xc.domain_start( dom=int(sys.argv[1]) )
os.close( fd )
return None
-def addr_of_iface( iface ):
- fd = os.popen( '/sbin/ifconfig '+iface )
- lines = fd.readlines()
- for line in lines:
- m = re.search( 'inet addr:([0-9.]+)', line )
- if m:
- return m.group(1)
- return None
-
-def add_to_ip( ip, off ):
+def add_offset_to_ip( ip, off ):
l = string.split(ip,'.')
- return '%s.%s.%s.%d' % ( l[0],l[1],l[2],string.atoi(l[3])+off )
+ a = ( (string.atoi(l[0])<<24) | (string.atoi(l[1])<<16) |
+ (string.atoi(l[2])<<8) | string.atoi(l[3]) ) + off
+
+ return '%d.%d.%d.%d' % ( ((a>>24)&0xff), ((a>>16)&0xff),
+ ((a>>8)&0xff), (a&0xff) )
else
{
/* For the moment, we are unable to move running
- domains between CPUs. (We need a way of cleanly stopping
- running domains). For now, if we discover the domain is
- running then cowardly bail out with ENOSYS */
+ domains between CPUs. (We need a way of synchronously
+ stopping running domains). For now, if we discover the
+ domain is not stopped already then cowardly bail out
+ with ENOSYS */
- if(p->flags & PF_CONSTRUCTED)
+ if( !(p->state & TASK_STOPPED) )
ret = -ENOSYS;
else
{
+ /* We need a task structure lock here!!!
+ FIX ME!! */
cpu = cpu % smp_num_cpus;
p->processor = cpu;
p->cpupinned = 1;